def valid_kwargs(**kwargs):
    def decorator(func):
        def wrapper(self, *args, **w_kwargs):
            for key in w_kwargs:
                if key not in kwargs:
                    raise TypeError("Invalid keyword argument: %s" % key)
            
            for (key, factory) in kwargs.items():
                if key in w_kwargs:
                    continue # skip set keys
                    
                if callable(factory):
                    w_kwargs[key] = factory()
                else:
                    w_kwargs[key] = factory
            
            return func(self, *args, **w_kwargs)
        return wrapper
    return decorator



